<template>
	<view class="user-index">
		
		<!--个人信息-->
		<view v-if="!loadding">
			<view class="user-header">
				<view class="user-header-inner">
					<view class="user-info">
						<view class="photo" >
							<image src="../../../static/dafaulthead2.png" v-if="detail.avatarUrl == ''"></image>
							<image :src="detail.avatarUrl" mode="aspectFill" v-else></image>
						</view>
						<view class="info msg">
							<view class="name">{{ detail.nickName }}</view>
							<image class="crown" src="../../../static/crown1.png"></image>

							<!-- <view class="tel d-s-c">
								<text class="f24">ID:{{ detail.user_id }}</text>
								<text class="ml20 grade" v-if="detail.grade_id > 0">
									<text class="icon iconfont icon-zhuanshutequan"></text>
									{{ detail.grade.name }}
								</text>
							</view> -->
							<view class="updateinfo" @click="gotoPage('/pages/user/updateinfo/updateinfo')">
								<text>编辑资料</text>
								<view>
									<image src="../../../static/updateinfo2.png"></image>
								</view>
							</view>
						</view>

					</view>
					<image class="setting" src="../../../static/setting2.png" @click="gotoPage('/pages/user/set/set')"></image>
					<!-- <view v-if="sign.is_open == 1" class="sign-box d-c-c" @click="gotoPage('/pages/plus/signin/signin')">
						<text class="icon iconfont icon-libao"></text>
						<text class="ml10">签到有礼</text>
					</view> -->
				</view>

				<view class="vip-wrap">
					<view class="vip-box">
						<view class="vip-box-l">
							<image src="../../../static/app/user/vip2.png" mode=""></image>
							<text>联合拉.超级会员</text>
						</view>
						<!-- <view class="vip-box-r" v-if="detail.grade_id == 1" @click="gotoPage('/pages/user/vip/vip')">
							立即开通
						</view>
						<view class="time" v-if="detail.grade_id > 1">			
							<view class="vip-time">
								{{vip_time}}到期
							</view>
							<view class="vip-next" @click="gotoPage('/pages/user/vip/renew/renew')"> > </view>
						</view> -->
					</view>
					<view class="vip-info">
						<view class="vip-icon">
							<image src="../../../static/app/user/vip.png" mode=""></image>
						</view>
						<text>开通会员可增加积分</text>
					</view>
				</view>

				<!--我的订单-->

				<!-- <view class="my-order">
					<view class="d-b-c">
						<view class="item" @click="gotoPage('/pages/order/myorder?dataType=payment')">
							<view class="icon-box pr">
								<span class="icon iconfont icon-icon"></span>
								<text class="dot d-c-c" v-if="orderCount.payment != null && orderCount.payment > 0">{{ orderCount.payment }}</text>
							</view>
							<text>待付款</text>
						</view>
						<view class="item" @click="gotoPage('/pages/order/myorder?dataType=received')">
							<view class="icon-box pr">
								<span class="icon iconfont icon-daishouhuo"></span>
								<text class="dot d-c-c" v-if="orderCount.received != null && orderCount.received > 0">{{ orderCount.received }}</text>
							</view>
							<text>待收货</text>
						</view>
						<view class="item" @click="gotoPage('/pages/order/myorder?dataType=comment')">
							<view class="icon-box pr">
								<span class="icon iconfont icon-quanbudingdan"></span>
								<text class="dot d-c-c" v-if="orderCount.comment != null && orderCount.comment > 0">{{ orderCount.comment }}</text>
							</view>
							<text>待评价</text>
						</view>
						<view class="item" @click="gotoPage('/pages/order/refund/index/index')">
							<view class="icon-box pr">
								<span class="icon iconfont icon-tuikuan"></span>
								<text class="dot d-c-c" v-if="orderCount.refund != null && orderCount.refund > 0">{{ orderCount.refund }}</text>
							</view>
							<text>退款/售后</text>
						</view>
						<view class="vertical">
							<image class="vertical_img" src="../../../static/vertical.png" mode=""></image>
						</view>
						<view class="item" @click="gotoPage('/pages/order/myorder?dataType=all')">
							<view class="icon-box"><span class="icon iconfont icon-quanbudingdan"></span></view>
							<text>全部订单</text>
						</view>
					</view>
				</view> -->
			</view>
			<!-- <view class="bind_phone" v-if="!detail.mobile">
				<view class="bind_content">
					<view class="bind_txt">点击绑定手机号，确保账户安全</view>
					<view class="bind_btn" @click="bindMobile">去绑定</view>
				</view>
			</view> -->
			<!--我的资产-->
			<view class="my-assets d-b-c">
				<view class="list d-a-c flex-1 mr30">
					<view class="item d-c-c d-c" @click="gotoPage('/pages/user/my-wallet/my-walletBox')">
						<view class="item-icon">
							<image src="../../../static/app/user/icon1.png" mode=""></image>
						</view>
						<text class="pt10 f24 gray3">我的钱包</text>
					</view>
					<view class="item d-c-c d-c" @click="gotoPage('/pages/user/orderRecord/orderRecord')">
						<view class="item-icon">
							<image src="../../../static/app/user/icon2.png" mode=""></image>
						</view>
						<text class="pt10 f24 gray3">接单记录</text>
					</view>
					<view class="item d-c-c d-c" @click="gotoPage('/pages/user/caseRecord/caseRecord')">
						<view class="item-icon">
							<image src="../../../static/app/user/icon3.png" mode=""></image>
						</view>
						<text class="pt10 f24 gray3">提现记录</text>
					</view>
					<view class="item d-c-c d-c" @click="gotoPage('/pages/user/my-account/my-account')">
						<view class="item-icon">
							<image src="../../../static/app/user/icon4.png" mode=""></image>
						</view>
						<text class="pt10 f24 gray3">账户管理</text>
					</view>
					<!-- <view class="item d-c-c d-c" @click="gotoPage('/pages/user/my-wallet/my-wallet')">
						<view class="f24 red_mini">{{ detail.balance }}<text class="f20">元</text></view>
						<text class="pt10 f24 gray3">账号余额</text>
					</view>
					<view class="item d-c-c d-c" @click="gotoPage('/pages/user/points/points')">
						<view class="f24 red_mini">{{ detail.points }}</view>
						<text class="pt10 f24 gray3">{{setting.points_name}}</text>
					</view>
					<view class="item d-c-c d-c" @click="gotoPage('/pages/user/my-coupon/my-coupon')">
						<view class="f24 red_mini">{{ coupon }}<text class="f20">张</text></view>
						<text class="pt10 f24 gray3">优惠券</text>
					</view> -->
				</view>
			</view>

			<view class="block-wrap">
				<view class="block-item" @click="gotoPage('/pages/user/shoppingmall/shoppingmall')">
					<view class="item-l">
						<view>积分商城</view>
						<!-- <text>天天兑换抢五折</text> -->
					</view>
					<view class="item-r">
						<image src="../../../static/app/user/icon6.png" mode=""></image>
					</view>
				</view>
				<!-- <view class="block-item" @click="gotoPage('/pages/user/record/record')">
					<view class="item-l">
						<view>兑奖记录</view>
						
					</view>
					<view class="item-r">
						<image src="../../../static/app/user/icon5.png" mode=""></image>
					</view>
				</view> -->
			</view>

			<view class="menu-wrap">
				<view class="menu-list">
					<view class="menu-item" @click="gotoPage('/pages/user/my-driver/my-driver')">
						<view class="item-l">
							<image src="../../../static/app/user/icon9.png" mode=""></image>
							<text>我的司机</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view>
					<!-- <view class="menu-item" @click="gotoPage('/pages/user/qrcode/qrcode')">
						<view class="item-l">
							<image src="../../../static/app/user/icon7.png" mode=""></image>
							<text>邀请好友</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view> -->
					<view class="menu-item" @click="gotoPage('/pages/user/my-car/my-car')">
						<view class="item-l">
							<image src="../../../static/app/user/icon8.png" mode=""></image>
							<text>我的车辆</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view>
					<!-- @click="gotoPage('/pages/user/user-car/user-car')" -->
					<view class="menu-item" @click="gotoPage('/pages/user/user-car/allUser_car/allUser_car')">
						<view class="item-l">
							<image src="../../../static/user-car.png" mode=""></image>
							<text>二手车</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view>
					
					
					<!-- <view class="menu-item" @click="gotoPage('/pages/user/myteam/myteam')">
						<view class="item-l">
							<image src="../../../static/myteam.png" mode=""></image>
							<text>我的团队</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view> -->
					<!-- <view class="menu-item" @click="gotoPage('/pages/user/join-us/join-us')">
						<view class="item-l">
							<image src="../../../static/app/user/icon10.png" mode=""></image>
							<text>加入我们</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view> -->
					<view class="menu-item" @click="gotoPage('/pages/user/qrcode/qrcode')">
						<view class="item-l">
							<image src="../../../static/app/user/icon7.png" mode=""></image>
							<text>邀请好友</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view>
					<view class="menu-item" @click="gotoPage('/pages/user/about-us/about-us')">
						<view class="item-l">
							<image src="../../../static/app/user/icon11.png" mode=""></image>
							<text>关于我们</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view>
					<view class="menu-item" @click="gotoPage('/pages/user/join-us/join-us')">
						<view class="item-l">
							<image src="../../../static/app/user/icon10.png" mode=""></image>
							<text>加入我们</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view>
					<view class="menu-item" @click="gotoPage('/pages/user/help-center/help-center')">
						<view class="item-l">
							<image src="../../../static/app/user/icon12.png" mode=""></image>
							<text>帮助中心</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view>
					<view class="menu-item" @click="gotoInfo">
						<view class="item-l">
							<image src="../../../static/app/user/icon4.png" mode=""></image>
							<text>认证信息</text>
						</view>
						<view class="item-r">
							<text class="icon iconfont icon-jiantou"></text>
						</view>
					</view>
				</view>
			</view>
			<view style="height: 150rpx;"></view>

			<!--菜单-->
			<!-- <view class="menu-wrap">
				<view class="group-bd f-w">
					<view :class="'item ' + item.icon + '-box'" v-for="(item, index) in menus" :key="index" @click="gotoPage(item.path)">
						<view class="icon-round d-c-c"><text :class="'icon iconfont ' + item.icon"></text></view>
						<text class="name">{{ item.name }}</text>
					</view>
				</view>
			</view> -->
			<!--推荐-->
			<!-- <view>
				<recommendProduct :location="20"></recommendProduct>
			</view> -->
		</view>
		<view class="mask" v-show="isShow"></view>
		<view class="bottom-dialog-wrap" v-show="isShow">
			<view class="info-wrap" @click="phoneCall">
				<view class="info-item">
					<image src="../../../static/app/phone.png" mode=""></image>
					<text>
						呼叫 {{phone}}
					</text>
				</view>
			</view>
			<view class="dialog-btn" @click="closePhone">
				取消
			</view>
		</view>
		<footTabber></footTabber>
	</view>
</template>

<script>
	import recommendProduct from '@/components/recommendProduct/recommendProduct.vue';
	export default {
		components: {
			recommendProduct
		},
		data() {
			return {
				/*签到数据*/
				sign: {},
				/*是否加载完成*/
				loadding: false,
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				/*菜单*/
				menus: [],
				detail: {					
					balance: 0,
					points: 0,
					grade: {
						name: ''
					},
				},
				is_recycle: 0,
				orderCount: {},
				coupon: 0,
				setting: {},
				user_type: '', //用户状态
				phone: '19167744084',
				isShow: false,
				vip_time:'2023-02-23',//会员到期时间
				driverIfno:'',
			};
		},
		onShow() {
			/*获取个人中心数据*/
			this.getData();
		},
		onLoad() {
			//let commonConfig = uni.getStorageSync('commonConfig');
		//	this.phone = '' + commonConfig['service_phone'];
			this.getinfo();
		},
		onPullDownRefresh() {
			this.getinfo();
			this.getData();
			setTimeout( () => {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			gotoInfo(){
				console.log(this.driverIfno)
				uni.navigateTo({
					url:'/pages/register/regist-info-Sbmitted/regist-info-Sbmitted'
				});
			},
			/* 获取司机认证信息 */
			getinfo(){
				let self = this;
				uni.showLoading({
					title: '加载中'
				});
				self._get('user.index/registerInfo', {}, function(res) {
						//console.log(res.data.Info)
					self.driverIfno	= res.data.Info;
					//console.log(self.driverIfno)
					//self.loadding = false;
					uni.hideLoading();
				});
			},
			/*获取个人数据*/
			getData() {
				let self = this;
				uni.showLoading({
					title: '加载中'
				});
				self._get('user.index/detail', {}, function(res) {
					//#ifdef MP-WEIXIN
					if (res.data.getPhone) {
						wx.navigateTo({
							url: "/pages/login/bindmobile"
						});
						return;
					}
										
					//#endif5
					self.detail = res.data.userInfo;	
					self.detail.avatarUrl = res.data.userInfo.avatarUrl,
					self.sign = res.data.sign;
					self.coupon = res.data.coupon;
					self.orderCount = res.data.orderCount;
					self.menus = res.data.menus;
					self.setting = res.data.setting;
					self.is_recycle = res.data.userInfo.is_recycle
					self.loadding = false;
					uni.hideLoading();
				});
			},
			bindMobile() {
				//小程序
				// #ifdef MP-WEIXIN
				uni.navigateTo({
					url: "/pages/login/bindmobile"
				});
				// #endif
				// 其他
				// #ifndef  H5
				uni.navigateTo({
					url: "/pages/user/modify-phone/modify-phone"
				});
				// #endif
			},
			/*跳转页面*/
			gotoPage(path) {
				let self = this;
				if (path.startsWith('/')) {
					uni.navigateTo({
						url: path
					});
				} else {
					self[path]();
				}
			},
			/*app扫一扫*/
			scanQrcode: function() {
				// 只允许通过相机扫码
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						uni.navigateTo({
							url: res.result
						})
					}
				});
			},
			phoneCall() {
				let self = this;
				uni.makePhoneCall({
					phoneNumber: self.phone
				});
			},
			showPhone() {
				let self = this;
				self.isShow = true;
			},
			closePhone() {
				let self = this;
				self.isShow = false;
			}
		}
	};
</script>

<style lang="scss">
	@import 'index.scss';
</style>
